<!--- 
*******************************************************************************
Copyright (C) 2006 Ryan Hickman (rhickman@gmail.com)
Copyright (C) 2006 Google Inc. (ASP version of this file)

 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*******************************************************************************


*************************************************
BEFORE USING PLEASE READ

Before using this installation test script, you
must install the ActiveX Com object onto your
Windows Server.
The COM library has been packaged as a .MSI file
and will automatically install into the 
Windows Component Services COM+ packages
You will see it show up as "GCrypt"

After running the .MSI installation, copy this
installation test .cfm page to your webserver
and simply call the page
*************************************************
--->

<!--- Leave this test string and test key as-is to verify the expected output which is hard-coded into the HTML below --->
<cfset str = "test_data">
<cfset key = "test_key">

<!--- Initiate the GCrypt COM object --->
<cfobject type = "com"
	action = "create"
	class = "GCrypt.g_crypt.2"
	name = "cryptobj">

<!---  BASE64-ENCODE (input data as String) - outputs base64 encoded binary string --->
<cfset  b64str = cryptObj.base64Encode(str)>

<!--- HMACSHA1(input data as String, secret key as String) - outputs base64 encoded binary string --->
<cfset  b64signature = cryptobj.generateSignature(str,key)>

<html>
<head>
    <title>GCrypt Installation Test Page</title>
</head>

<body>
    <center>
        <h1>HMAC-SHA1 and Base64-Encode Test Page</h1>
    </center>

    <table border='1' width="800">
        <tr>
            <td>String used for calculations:</td>

            <td>test_data</td>
        </tr>
        <tr>
            <td>String used as key:</td>
            <td>test_key</td>
        </tr>

        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <td>Base64 Encoded String Calculated by GCrypt</td>

            <td><cfoutput>#b64str#</cfoutput></td>
        </tr>
        <tr>
            <td>Expected Base64 Encoding of the String</td>

            <td>dGVzdF9kYXRh</td>
        </tr>
        <tr>
            <td colspan='2'>&nbsp;</td>
        </tr>
        <tr>
            <td>Base64 Encoding of HMAC-SHA1 Calculated by GCrypt</td>

            <td><cfoutput>#b64signature#</cfoutput></td>
        </tr>
        <tr>
            <td>Expected Base64 Encoding of HMAC-SHA1 Signature</td>

            <td>2G2Jv74LpjS1Emu6tJRrTES/Dlw=</td>
        </tr>
    </table>
</body>
</html>
